//
//  KnowledgeTableViewCell.m
//  CookGuest
//
//  Created by LiuYanJun on 15/9/12.
//  Copyright (c) 2015年 杨元石. All rights reserved.
//

#import "KnowledgeTableViewCell.h"

@implementation KnowledgeTableViewCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        CGFloat xlen = (SCREEN_WIDTH - ADJUSTWIDTH*10 );   //图片宽度
        CGFloat ylen = ADJUSTHEIGHT*180;   //图片高度
        
        self.img = [[UIImageView alloc]initWithFrame:CGRectMake(ADJUSTWIDTH*5, ADJUSTHEIGHT*5, xlen, ylen)];
        self.img.layer.cornerRadius = 5;
        self.img.layer.masksToBounds = YES;
        [self.contentView addSubview:self.img];
        
        
        self.title_Label = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH*20 , ADJUSTHEIGHT*15 ,SCREEN_WIDTH - ADJUSTWIDTH*30, 30)];
        self.title_Label.numberOfLines = 1;
        self.title_Label.font = [UIFont boldSystemFontOfSize:20];
        self.title_Label.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.title_Label];
        
        
        self.allClick_Label = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH*20, ADJUSTHEIGHT*50, ADJUSTWIDTH*180, ADJUSTHEIGHT*30)];
        self.allClick_Label.font = [UIFont systemFontOfSize:17];
        self.allClick_Label.textColor = [UIColor whiteColor];
        [self.contentView addSubview:self.allClick_Label];
        
        
        self.content_Label = [[UILabel alloc]initWithFrame:CGRectMake(ADJUSTWIDTH*20, ADJUSTHEIGHT*150 ,SCREEN_WIDTH - ADJUSTWIDTH*30, ADJUSTHEIGHT*30)];
        self.content_Label.numberOfLines = 2;
        self.content_Label.textColor = [UIColor whiteColor];
        self.content_Label.font =[UIFont systemFontOfSize:17];
        [self.contentView addSubview:self.content_Label];
        
        
    }
    return self;
}


-(void)getModel:(KnowledgeModel *)getModel
{
    [self.img sd_setImageWithURL:[NSURL URLWithString:getModel.img] placeholderImage:[UIImage imageNamed:@"default"]];
    self.title_Label.text = getModel.title;
    
    self.content_Label.text = [NSString stringWithFormat:@"%@...",[getModel.content substringToIndex:20]];
    
    self.allClick_Label.text = [NSString stringWithFormat:@"%@浏览",getModel.allClick];
    
}



/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
